]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
inputMethod: Handle OSK hiding after unfocus
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 8 Feb 2019 22:00:18 +0000 (23:00 +0100)
committerCarlos Garnacho <mrgarnacho@gmail.com>
Mon, 4 Mar 2019 18:24:38 +0000 (18:24 +0000)
Set a small timeout in order to let focus changes preserve OSK state. If
focus is eventually unset, the OSK will be hidden.

https://gitlab.gnome.org/GNOME/gtk/issues/1277
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/397

js/misc/inputMethod.js

index ce2002a09de8c98e3053e44c38ef855179f13ba7..8d46264e14db033b46230bbd8a00196f09300a16 100644 (file)
@@ -1,8 +1,10 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-const { Clutter, GObject, IBus } = imports.gi;
+const { Clutter, GLib, GObject, IBus } = imports.gi;
 
 const Keyboard = imports.ui.status.keyboard;
 
+var HIDE_PANEL_TIME = 50;
+
 var InputMethod = GObject.registerClass(
 class InputMethod extends Clutter.InputMethod {
     _init() {
@@ -13,6 +15,7 @@ class InputMethod extends Clutter.InputMethod {
         this._preeditStr = '';
         this._preeditPos = 0;
         this._preeditVisible = false;
+        this._hidePanelId = 0;
         this._ibus = IBus.Bus.new_async();
         this._ibus.connect('connected', this._onConnected.bind(this));
         this._ibus.connect('disconnected', this._clear.bind(this));
@@ -136,6 +139,11 @@ class InputMethod extends Clutter.InputMethod {
             this._updateCapabilities();
             this._emitRequestSurrounding();
         }
+
+        if (this._hidePanelId) {
+            GLib.source_remove(this._hidePanelId);
+            this._hidePanelId = 0;
+        }
     }
 
     vfunc_focus_out() {
@@ -150,6 +158,12 @@ class InputMethod extends Clutter.InputMethod {
             this.set_preedit_text(null, 0);
             this._preeditStr = null;
         }
+
+        this._hidePanelId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, HIDE_PANEL_TIME, () => {
+            this.set_input_panel_state(Clutter.InputPanelState.OFF);
+            this._hidePanelId = 0;
+            return GLib.SOURCE_REMOVE;
+        });
     }
 
     vfunc_reset() {